package com.quyu;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

@Slf4j
@SpringBootTest
public class MyClient {
    @Test
    public void test() {
       try {
           Socket socket = new Socket(" 192.168.247.1",8888);
           InputStream is = socket.getInputStream();
           OutputStream os = socket.getOutputStream();
           os.write("hello".getBytes());
           byte[] bytes = new byte[1024];
           log.info("客户端收到消息：{}",new String(bytes,0,is.read(bytes)));
           os.flush();
           os.close();
       }catch (Exception e){
           log.error("客户端异常",e);
       }



    }
}
